package com.ssy.lingxi.platform.manage.serviceimpl;

import com.ssy.lingxi.common.constant.basic.EnableDisableStatus;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.entity.base.CountryArea;
import com.ssy.lingxi.platform.manage.repository.CountryAreaRepository;
import com.ssy.lingxi.platform.manage.service.ICountryAreaService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @menu 国家 - 业务实现层
 * @author fhj
 * @version 2.0.0
 * @date 2020/7/20
 */
@Service
public class CountryAreaServiceImpl implements ICountryAreaService {

    @Resource
    private CountryAreaRepository countryAreaRepository;

    /**
     * 查询手机区号
     * */
    @Override
    public Wrapper<List<String>> listAreaCode() {
        List<CountryArea> allByState = countryAreaRepository.findAllByState(EnableDisableStatus.ENABLE.getCode());
        List<String> areaCodeList = allByState.stream().map(CountryArea::getTelCode).collect(Collectors.toList());
        return Wrapper.success(areaCodeList);
    }
}
